#pragma once
#include <iostream>
using namespace std;
#include <cstring>
#include <string.h>
#define SEP " "
#define SEP_LEN strlen(SEP)

const string &enLength(const string &text)
{
}

const string &deLength(const string &package)
{
}

class Request
{
public:
    Request() {}
    Request() : _x(0), _y(0), _op(0)
    {
    }

    // 序列化
    bool serialize(string *out)
    {
        *out = "";

        string x_string = to_string(_x);
        string y_string = to_string(_y);

        // x op y
        *out = x_string;
        *out += SEP;
        *out += _op;
        *out += SEP;
        *out += y_string;

        return true;
    }

    // 反序列化
    bool deserialize(const string &in)
    {
        // x op yyy
        auto left = in.find(SEP);
        auto right = in.rfind(SEP);
        if (left == string::npos || right == string::npos)
            return false;
        if (left == right)
            return false;
        if (right - (left + SEP_LEN) != 1)
            return false;

        string x_string = in.substr(0, left);
        string y_string = in.substr(right + SEP_LEN);

        if (x_string.empty())
            return false;
        if (y_string.empty())
            return false;

        _x = stoi(x_string);
        _y = stoi(y_string);
        _op = in[left + SEP_LEN];

        return true;
    }

public:
    int _x;
    int _y;
    char _op;
};

class Response
{
public:
    Response() {}
    Response() : _exitcode(0), _result(0)
    {
    }
    bool serialize()
    {
    }

    bool deserialize()
    {
    }

public:
    int _exitcode; // 0表示结果正确
    int _result;
};